package com.java.dao;

import java.sql.Connection;
import java.util.ArrayList;
import java.util.HashMap;

import com.java.util.DaoUtils;

public class ComSmsInsertDao extends CommonDao{
	
	public ArrayList execute(HashMap requestMap,Connection con) {

		ArrayList list = new ArrayList();
		int result = 0;
		try {
			String queryStr = "call edu_CommonSmsInsert(?, ?, ?, ?, ?, ?, ?)";
			
			int checked_length 		= (Integer)requestMap.get("checked_length");
			String reserve_time 	= (String)requestMap.get("reserve_time");
			String uni_id[] 		= (String[])requestMap.get("uni_id");
			String dest_phone[] 	= (String[])requestMap.get("dest_phone");
			String send_phone_num 	= (String)requestMap.get("send_phone_num");
			String send_date_act 	= (String)requestMap.get("send_date_act");
			String user_id[] 		= (String[])requestMap.get("user_id");
			String send_text 		= (String)requestMap.get("send_text");
			
			String param[] = new String[7];
			for(int i=0; i<checked_length; i++){
				int result1 = 0;
				param[0] = reserve_time;
				param[1] = uni_id[i];
				param[2] = dest_phone[i];
				param[3] = send_phone_num;
				param[4] = send_date_act;
				param[5] = user_id[i];
				param[6] = send_text;
				result1 = DaoUtils.update(con, queryStr, param);
				
				result = result + result1;
			}
			
			list.add(result);

		} catch (Exception ee) {
			ee.printStackTrace();
		}finally {
			try{
				if (con!=null) con.setAutoCommit(true);
				if (con!=null) con.close();
			}catch(Exception ee){}
		}
		return list;
	}
}
